//
//  YZMTimeJudge.m
//  YZMicroStock
//
//  Created by apple on 17/3/8.
//  Copyright © 2017年 cqjr. All rights reserved.
//

#import "YZMTimeJudge.h"
#import "YZMSeverTimeService.h"

@implementation YZMTimeJudge

+(NSString *)compareCurrentTime:(NSDate *)compareDate{
    
    NSTimeInterval timeInterval = [compareDate timeIntervalSinceDate:[YZMSeverTimeService sharedService].severDate];
    timeInterval = -timeInterval;
    NSString *result;
    if (timeInterval < 60) {
        
        result = [NSString stringWithFormat:@"%d秒钟前",(int)timeInterval];
    }
    
    else if (timeInterval < 120) {
        result = [NSString stringWithFormat:@"1分钟前"];
    }
    
    else if(timeInterval<3600){
        result = [NSString stringWithFormat:@"%d分钟前",(int)(timeInterval/60)];
    }
    
    else if(timeInterval <3600*24){
        result = [NSString stringWithFormat:@"%d小时前",(int)(timeInterval/3600)];
    }
    
    else {
        result = [NSString stringWithFormat:@"%d天前",(int)(timeInterval/3600/24)];
    }
    
    return  result;
}

@end
